import {
  isUndefined,
  _pick,
} from "mmb";
import { getBrandSpokesmanInfo } from "./brandSpokesmanService"

// 考虑用缓存
export const checkSpokesman = async (
  userId: string,
  spokesmanId: string
) => {
  let cacheItem = await getBrandSpokesmanInfo(spokesmanId);
  if (isUndefined(cacheItem)) {
    console.log(`not found spokesman:${spokesmanId},${userId}`);
    return false;
  }
  if (cacheItem.userId !== userId) {
    console.log(`mismatch spokesman:${spokesmanId},${userId}`);
    return false;
  }

  return true;
};